include(cc_library)
include(cc_test)

cc_library(
  NAME
    util
  HDRS
    blocking_counter.h
    blockingconcurrentqueue.h
    closure_guard.h
    concurrentqueue.h
    device_name_utils.h
    double_buffer.h
    env_var.h
    hash_util.h
    http_downloader.h
    json_reader.h
    lightweightsemaphore.h
    net.h
    pretty_print.h
    scope_guard.h
    slice.h
    spin_lock.h
    spin_rw_lock.h
    tensor_helper.h
    threadpool.h
    timer.h
    type_traits.h
    utils.h
    uuid.h
    shared_memory_manager.h
  SRCS
    device_name_utils.cpp
    env_var.cpp
    http_downloader.cpp
    json_reader.cpp
    net.cpp
    pretty_print.cpp
    threadpool.cpp
    timer.cpp
    utils.cpp
    uuid.cpp
    shared_memory_manager.cpp
  DEPS
    torch
    brpc
    nlohmann_json::nlohmann_json
    glog::glog
    torch
    $<$<BOOL:${USE_NPU}>:torch_npu>
    $<$<BOOL:${USE_NPU}>:ms_tools_ext>
    Boost::serialization
    absl::synchronization
    ${Python_LIBRARIES}
    :platform
)
target_link_libraries(util PRIVATE OpenSSL::SSL OpenSSL::Crypto)
add_dependencies(util brpc-static)

cc_test(
  NAME
    util_test
  SRCS
    blocking_counter_test.cpp
    threadpool_test.cpp
  DEPS
    util
    absl::synchronization
    absl::time
    GTest::gtest_main
    gflags::gflags
)
target_link_libraries(util_test PRIVATE brpc leveldb::leveldb OpenSSL::SSL OpenSSL::Crypto)
add_dependencies(util_test brpc-static)





